﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using FDEECommonTools;
using FDEEInterface;
using FDEEPublicFunc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEEDrawingModels
{
    public class PlotPlinthTable
    {
        /// <summary>
        /// 垫石坐标绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="scale"></param>
        /// <param name="dwgPath"></param>
        public static void DrawPlinthTable(Database db, double scale, string dwgPath, string filepath, string title = "MAINLINE",string tkPath="")
        {
            Extents2d ext = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d ext1 = new Extents2d(Point2d.Origin, Point2d.Origin);
            Point2d CT = Point2d.Origin.Convert2D(0, -2 * scale);
            Point2d M1 = CT;
            ext = new Extents2d(M1, M1);
            System.Data.DataTable dtA = new System.Data.DataTable();
            System.Data.DataTable dtB = new System.Data.DataTable();
            //System.Data.DataTable dt= CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WeChat Files\wxid_1fmp3vdht5sl22\FileStorage\File\2021-12\P266-P294垫石坐标+高程.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\P-295-P-335垫石坐标.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-2 垫石坐标(1).csv");
            System.Data.DataTable dt;//= CVSTools.OpenCSV(@"C:\Users\huajie\Desktop\FDEE_Data\Banani EX-1 垫石坐标.csv");
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filepath);
            if (fileInfo.Extension.Contains("xlsx"))
                dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
            else
                dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
            DataView dv0 = dt.DefaultView;
            dt = dv0.ToTable(true, new string[] { "Pier", "Side", "PlinthNo", "East", "North" });

            System.Data.DataTable dtP = new System.Data.DataTable();
            DataView dv = dt.DefaultView;
            dtP = dv.ToTable(true, new string[] { "Pier" });
            if (dtP.Rows.Count > 0)
            {
                for (int i = 0; i < dtP.Rows.Count; i++)
                //for (int i = 1; i < 6; i++)
                {

                    DataRow dr = dtP.Rows[i];
                    string pierName = dr[0].ToString();
                    DataRow[] drsA = dt.Select("Pier='" + dr[0] + "' and Side='A'");
                    dtA = dt.Clone();
                    if (drsA.Length > 0)
                    {
                        foreach (DataRow item in drsA)
                        {
                            dtA.ImportRow(item);
                        }
                    }
                    DataRow[] drsB = dt.Select("Pier='" + dr[0] + "' and Side='B'");
                    dtB = dt.Clone();
                    if (drsB.Length > 0)
                    {
                        foreach (DataRow item in drsB)
                        {
                            dtB.ImportRow(item);
                        }
                    }
                    //string title = "MAINLINE";//修改
                    //string title = "RAMP BANANI EX-2";//修改
                    //string title = "RAMP BANANI EX-1";//修改
                    Table lasTb = new Table();
                    ext = new Extents2d(M1.Convert2D(0, -297 * i), M1.Convert2D(0, -297 * i));
                    if (title == "MAINLINE")
                    {
                        lasTb = DrawingPlinthTable(db, ref ext, M1.Convert3D(0, -297 * i),
                            Extensions.curFont, scale, dtA, dtB, pierName, dwgPath, title);
                        double width = lasTb.Width;
                        double height = 0;
                        if (lasTb != null)
                        {
                            string str1 = string.Format("COORDINATES OF BEARING PLINTH FOR '{0}' OF {1}", pierName, title);
                            string str2 = "";
                            TextPloter.PrintScaleDoubleSideText(db, M1.Convert2D(0, -297 * i).Convert2D(width, 8 * scale), 3, str1, str2, ref ext, scale, Extensions.curFont);
                        }
                    }
                    else
                    {
                        lasTb = DrawingRampPlinthTable(db, ref ext, M1.Convert3D(0, -297 * i),
                     Extensions.curFont, scale, dtA, dtB, pierName, dwgPath, title);
                        double width = lasTb.Width;
                        double height = 0;
                        if (lasTb != null)
                        {
                            string str1 = string.Format("COORDINATES OF BEARING PLINTH FOR '{0}' OF {1}", pierName, title);
                            string str2 = "";
                            TextPloter.PrintScaleDoubleSideText(db, M1.Convert2D(0, -297 * i).Convert2D(width*0.5, 8 * scale), 3, str1, str2, ref ext, scale, Extensions.curFont);
                        }
                    }

                 
                    Common.CreateLayoutNew(db, "垫石坐标数据表", ext, scale, 1, i, 0,false,tkPath);
                }

            }
        }
        /// <summary>
        ///  垫石坐标表格绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="startPoint"></param>
        /// <param name="txtStyle"></param>
        /// <param name="scale"></param>
        /// <param name="tbAValue"></param>
        /// <param name="tbBValue"></param>
        /// <param name="pierName"></param>
        /// <param name="_dwgPath"></param>
        /// <param name="Title"></param>
        /// <returns></returns>
        public static Table DrawingPlinthTable(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataTable tbAValue, System.Data.DataTable tbBValue, string pierName, string _dwgPath, string Title = "MAINLINE")
        {


            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                ObjectId id;
                TextStyleTable st = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                id = st[txtStyle];

                int tCount = tbAValue.Rows.Count / 4;
                //int tCount = 44 / 4;
                if (tbBValue.Rows.Count / 4 > tCount)
                    tCount = tbBValue.Rows.Count / 4;
                int halfNum = tCount / 2;
                if (halfNum < tCount / 2.0)
                    halfNum += 1;
                int rowNum = halfNum * 4 + 4;


                Table tb = new Table();
                #region  表格
                for (int n = 0; n < 2; n++)
                {
                    startPoint = startPoint.Convert3D(tb.Width);
                    tb = new Table();
                    int colNum = 7;
                    tb.SetSize(rowNum, colNum);       // 设置几行几列
                    tb.Position = startPoint;
                    tb.GenerateLayout();

                    #region 设置列宽
                    // 设置列宽
                    for (int i = 0; i < colNum; ++i)
                    {
                        tb.Columns[i].Width = 6 * 3 * scale;
                    }


                    //行高
                    for (int i = 0; i < rowNum; ++i)
                    {
                        tb.Rows[i].Height = 6 * scale;
                    }
                    #endregion



                    tb.Cells[0, 0].TextString = "Location"; //获取i行j列数据
                    tb.Cells[0, 0].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[0, 0].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[0, 0].Contents[0].Rotation = 0;
                    tb.Cells[0, 0].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[0, 0].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0));

                    tb.Cells[0, 1].TextString = pierName; //获取i行j列数据
                    tb.Cells[0, 1].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[0, 1].Contents[0].Rotation = 0;
                    tb.Cells[0, 1].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[0, 1].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 0, 1, 0, 6));


                    tb.Cells[2, 0].TextString = Title; //获取i行j列数据
                    tb.Cells[2, 0].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[2, 0].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[2, 0].Contents[0].Rotation = 0;
                    tb.Cells[2, 0].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[2, 0].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 2, 0, rowNum - 1, 0));

                    tb.Cells[1, 1].TextString = "Bearing\\P plinth No."; //获取i行j列数据
                    tb.Cells[1, 1].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[1, 1].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[1, 1].Contents[0].Rotation = 0;
                    tb.Cells[1, 1].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[1, 1].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 1, 1, 3, 1));

                    tb.Cells[1, 2].TextString = "A"; //获取i行j列数据
                    tb.Cells[1, 2].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[1, 2].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[1, 2].Contents[0].Rotation = 0;
                    tb.Cells[1, 2].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[1, 2].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 1, 2, 1, 3));

                    tb.Cells[1, 4].TextString = "Bearing\\P plinth No."; //获取i行j列数据
                    tb.Cells[1, 4].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[1, 4].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[1, 4].Contents[0].Rotation = 0;
                    tb.Cells[1, 4].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[1, 4].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 1, 4, 3, 4));

                    tb.Cells[1, 5].TextString = "B"; //获取i行j列数据
                    tb.Cells[1, 5].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[1, 5].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[1, 5].Contents[0].Rotation = 0;
                    tb.Cells[1, 5].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[1, 5].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 1, 5, 1, 6));

                    tb.Cells[2, 2].TextString = "Coordinates (m)"; //获取i行j列数据
                    tb.Cells[2, 2].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[2, 2].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[2, 2].Contents[0].Rotation = 0;
                    tb.Cells[2, 2].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[2, 2].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 2, 2, 2, 3));

                    tb.Cells[2, 5].TextString = "Coordinates (m)"; //获取i行j列数据
                    tb.Cells[2, 5].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[2, 5].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[2, 5].Contents[0].Rotation = 0;
                    tb.Cells[2, 5].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[2, 5].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, 2, 5, 2, 6));

                    tb.Cells[3, 2].TextString = "N."; //获取i行j列数据
                    tb.Cells[3, 2].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[3, 2].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[3, 2].Contents[0].Rotation = 0;
                    tb.Cells[3, 2].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[3, 2].Contents[0].TextStyleId = id;

                    tb.Cells[3, 3].TextString = "E."; //获取i行j列数据
                    tb.Cells[3, 3].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[3, 3].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[3, 3].Contents[0].Rotation = 0;
                    tb.Cells[3, 3].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[3, 3].Contents[0].TextStyleId = id;


                    tb.Cells[3, 5].TextString = "N."; //获取i行j列数据
                    tb.Cells[3, 5].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[3, 5].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[3, 5].Contents[0].Rotation = 0;
                    tb.Cells[3, 5].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[3, 5].Contents[0].TextStyleId = id;

                    tb.Cells[3, 6].TextString = "E."; //获取i行j列数据
                    tb.Cells[3, 6].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[3, 6].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[3, 6].Contents[0].Rotation = 0;
                    tb.Cells[3, 6].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[3, 6].Contents[0].TextStyleId = id;
                    if (n == 0)
                    {
                        for (int i = 0; i < halfNum * 4; i++)
                        {
                            //A
                            if (i < tbAValue.Rows.Count)
                            {
                                string val = tbAValue.Rows[i]["PlinthNo"].ToString();
                                if (val.Contains("13") || val.Contains("14") || val.Contains("15") || val.Contains("16") || val.Contains("17") || val.Contains("18") || val.Contains("19") || val.Contains("20") || val.Contains("21"))
                                {
                                    string vt = val.Replace("月", "-").Replace("日", "");
                                    val = vt.Split('-')[1] + "-" + vt.Split('-')[0];
                                }
                                else
                                    val = val.Replace("月", "-").Replace("日", "");
                                tb.Cells[4 + i, 1].TextString = val;// tbAValue.Rows[i]["PlinthNo"].ToString().ToString().Replace("月", "-").Replace("日", ""); ; //获取i行j列数据
                                tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[i]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                            }

                            //B
                            if (i < tbBValue.Rows.Count)
                            {
                                string val = tbBValue.Rows[i]["PlinthNo"].ToString();
                                if (val.Contains("13") || val.Contains("14") || val.Contains("15") || val.Contains("16") || val.Contains("17") || val.Contains("18") || val.Contains("19") || val.Contains("20") || val.Contains("21"))
                                {
                                    string vt = val.Replace("月", "-").Replace("日", "");
                                    val = vt.Split('-')[1] + "-" + vt.Split('-')[0];
                                }
                                else
                                    val = val.Replace("月", "-").Replace("日", "");
                                tb.Cells[4 + i, 4].TextString = val;// tbBValue.Rows[i]["PlinthNo"].ToString().ToString().Replace("月", "-").Replace("日", ""); ;//获取i行j列数据
                                tb.Cells[4 + i, 4].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 4].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 4].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 4].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 4].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 5].TextString = double.Parse(tbBValue.Rows[i]["North"].ToString()).ToString("0.000");  //获取i行j列数据
                                tb.Cells[4 + i, 5].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 5].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 5].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 5].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 5].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 6].TextString = double.Parse(tbBValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 6].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 6].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 6].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 6].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 6].Contents[0].TextStyleId = id;
                            }                            
                        }
                    }
                    else
                    {
                        for (int m = halfNum * 4; m < halfNum * 8; m++)
                        {
                            int i = m - halfNum * 4;
                            //A
                            if (m < tbAValue.Rows.Count)
                            {
                                string val = tbAValue.Rows[m]["PlinthNo"].ToString();
                                if (val.Contains("13") || val.Contains("14") || val.Contains("15") || val.Contains("16") || val.Contains("17") || val.Contains("18") || val.Contains("19") || val.Contains("20") || val.Contains("21"))
                                {
                                    string vt = val.Replace("月", "-").Replace("日", "");
                                    val = vt.Split('-')[1] + "-" + vt.Split('-')[0];
                                }
                                else
                                    val = val.Replace("月", "-").Replace("日", "");
                                tb.Cells[4 + i, 1].TextString = val; //获取i行j列数据
                                tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[m]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[m]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                            }

                            //B
                            if (m < tbBValue.Rows.Count)
                            {
                                string val = tbBValue.Rows[m]["PlinthNo"].ToString();
                                if (val.Contains("13") || val.Contains("14") || val.Contains("15") || val.Contains("16") || val.Contains("17") || val.Contains("18") || val.Contains("19") || val.Contains("20") || val.Contains("21"))
                                {
                                    string vt= val.Replace("月", "-").Replace("日", "");
                                    val = vt.Split('-')[1] + "-" + vt.Split('-')[0];
                                }
                                else
                                    val = val.Replace("月", "-").Replace("日", "");
                                tb.Cells[4 + i, 4].TextString = val;//获取i行j列数据
                                tb.Cells[4 + i, 4].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 4].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 4].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 4].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 4].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 5].TextString = double.Parse(tbBValue.Rows[m]["North"].ToString()).ToString("0.000");  //获取i行j列数据
                                tb.Cells[4 + i, 5].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 5].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 5].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 5].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 5].Contents[0].TextStyleId = id;

                                tb.Cells[4 + i, 6].TextString = double.Parse(tbBValue.Rows[m]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                                tb.Cells[4 + i, 6].Contents[0].TextHeight = 2 * scale;
                                tb.Cells[4 + i, 6].Alignment = CellAlignment.MiddleCenter;
                                tb.Cells[4 + i, 6].Contents[0].Rotation = 0;
                                tb.Cells[4 + i, 6].Borders.Horizontal.Margin = 1 * scale;
                                tb.Cells[4 + i, 6].Contents[0].TextStyleId = id;
                            }

                            if (halfNum * 8 - tbAValue.Rows.Count > 0)
                            {
                                for (int k = (halfNum + 1) * 4 - (halfNum * 8 - tbAValue.Rows.Count); k < rowNum; k++)
                                {
                                    tb.Cells[k, 1].TextString = " "; //获取i行j列数据
                                    tb.Cells[k, 1].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 1].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 1].Contents[0].Rotation = 0;
                                    tb.Cells[k, 1].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 1].Contents[0].TextStyleId = id;

                                    tb.Cells[k, 2].TextString = " "; //获取i行j列数据
                                    tb.Cells[k, 2].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 2].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 2].Contents[0].Rotation = 0;
                                    tb.Cells[k, 2].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 2].Contents[0].TextStyleId = id;

                                    tb.Cells[k, 3].TextString = " "; //获取i行j列数据
                                    tb.Cells[k, 3].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 3].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 3].Contents[0].Rotation = 0;
                                    tb.Cells[k, 3].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 3].Contents[0].TextStyleId = id;
                               
                                }
                            }

                            if (halfNum * 8 - tbBValue.Rows.Count > 0)
                            {
                                for (int k = (halfNum + 1) * 4 - (halfNum * 8 - tbBValue.Rows.Count); k < rowNum; k++)
                                {                                   

                                    tb.Cells[k, 4].TextString = " ";  //获取i行j列数据
                                    tb.Cells[k, 4].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 4].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 4].Contents[0].Rotation = 0;
                                    tb.Cells[k, 4].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 4].Contents[0].TextStyleId = id;

                                    tb.Cells[k, 5].TextString = " ";  //获取i行j列数据
                                    tb.Cells[k, 5].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 5].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 5].Contents[0].Rotation = 0;
                                    tb.Cells[k, 5].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 5].Contents[0].TextStyleId = id;

                                    tb.Cells[k, 6].TextString = " "; //获取i行j列数据
                                    tb.Cells[k, 6].Contents[0].TextHeight = 2 * scale;
                                    tb.Cells[k, 6].Alignment = CellAlignment.MiddleCenter;
                                    tb.Cells[k, 6].Contents[0].Rotation = 0;
                                    tb.Cells[k, 6].Borders.Horizontal.Margin = 1 * scale;
                                    tb.Cells[k, 6].Contents[0].TextStyleId = id;
                                }
                            }
                        }
                    }

                    tb.Layer = "细线";
                    tb.LineWeight = LineWeight.LineWeight013;
                    tb.ColorIndex = 4;
                    modelSpace.AppendEntity(tb);
                    tr.AddNewlyCreatedDBObject(tb, true);
                    ext = ext.Add(new Extents2d(tb.Bounds.Value.MinPoint.Convert2D(), tb.Bounds.Value.MaxPoint.Convert2D()));
                }
                #endregion


                #region  边框粗线设置
                List<Point2d> pList = new List<Point2d>();
                Point2d pt1 = startPoint.Convert2D(-tb.Width);
                pList.Add(pt1);
                Point2d pt2 = pt1.Convert2D(0, -tb.Height);
                pList.Add(pt2);
                Point2d pt3 = pt1.Convert2D(tb.Width * 2, -tb.Height);
                pList.Add(pt3);
                Point2d pt4 = pt1.Convert2D(tb.Width * 2, 0);
                pList.Add(pt4);
                PolylinePloter.AddPolylineByList(db, ref ext, pList, "粗线", 2);
                #endregion
                string _blcName = "Model1";
                db.CopyBlockFromFile(_dwgPath, _blcName);

                BlockTool.InsertBlockReference(pt4.Convert3D(45, -10), 1, _blcName, _dwgPath, ref ext, 0);

                _blcName = "Model2";
                db.CopyBlockFromFile(_dwgPath, _blcName);
                Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
                Dictionary<string, string> dic = new Dictionary<string, string>();
                int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(pierName, @"[^0-9]+", "").ToString());
                string stN = pierName.Replace(pierNo.ToString(), "") + (pierNo - 1);
                string edN = pierName.Replace(pierNo.ToString(), "") + (pierNo + 1);

                dic.Add(stN, "string");
                dicA.Add("NOS", dic);

                dic = new Dictionary<string, string>();
                dic.Add(edN, "string");
                dicA.Add("NOE", dic);

                dic = new Dictionary<string, string>();
                dic.Add("A", "string");
                dicA.Add("A", dic);


                dic = new Dictionary<string, string>();
                dic.Add("B", "string");
                dicA.Add("B", dic);

                BlockTool.InsertBlockReference(pt4.Convert3D(20, -150), 1, _blcName, _dwgPath, dicA, null, ref ext);

                //BlockTool.InsertBlockReference(pt4.Convert3D(45, -90), 1, _blcName, _dwgPath, ref ext, 0);
                Point2d pNote = pt2.Convert2D(0, -2);



                tr.Commit();
                return tb;
            }
        }
        /// <summary>
        /// 匝道垫石坐标表格绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="startPoint"></param>
        /// <param name="txtStyle"></param>
        /// <param name="scale"></param>
        /// <param name="tbAValue"></param>
        /// <param name="tbBValue"></param>
        /// <param name="pierName"></param>
        /// <param name="_dwgPath"></param>
        /// <param name="Title"></param>
        /// <returns></returns>
        public static Table DrawingRampPlinthTable(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataTable tbAValue, System.Data.DataTable tbBValue, string pierName, string _dwgPath, string Title = "MAINLINE")
        {


            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                ObjectId id;
                TextStyleTable st = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                id = st[txtStyle];

                int tCount = tbAValue.Rows.Count;
                //int tCount = 44 / 4;
                if (tbBValue.Rows.Count > tCount)
                    tCount = tbBValue.Rows.Count;
                //int halfNum = tCount / 2;
                //if (halfNum < tCount / 2.0)
                //    halfNum += 1;
                int rowNum = tCount + 4;


                Table tb = new Table();
                #region  表格

                startPoint = startPoint.Convert3D();
                tb = new Table();
                int colNum = 7;
                tb.SetSize(rowNum, colNum);       // 设置几行几列
                tb.Position = startPoint;
                tb.GenerateLayout();

                #region 设置列宽
                // 设置列宽
                for (int i = 0; i < colNum; ++i)
                {
                    tb.Columns[i].Width = 6 * 3 * scale;
                }


                //行高
                for (int i = 0; i < rowNum; ++i)
                {
                    tb.Rows[i].Height = 6 * scale;
                }
                #endregion



                tb.Cells[0, 0].TextString = "Location"; //获取i行j列数据
                tb.Cells[0, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 0].Contents[0].Rotation = 0;
                tb.Cells[0, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0));

                tb.Cells[0, 1].TextString = pierName; //获取i行j列数据
                tb.Cells[0, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 1].Contents[0].Rotation = 0;
                tb.Cells[0, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 1].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 1, 0, 6));


                tb.Cells[2, 0].TextString = Title; //获取i行j列数据
                tb.Cells[2, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 0].Contents[0].Rotation = 0;
                tb.Cells[2, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 0, rowNum - 1, 0));

                tb.Cells[1, 1].TextString = "Bearing\\P plinth No."; //获取i行j列数据
                tb.Cells[1, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 1].Contents[0].Rotation = 0;
                tb.Cells[1, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 1].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 1, 3, 1));

                tb.Cells[1, 2].TextString = "A"; //获取i行j列数据
                tb.Cells[1, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 2].Contents[0].Rotation = 0;
                tb.Cells[1, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 2].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 2, 1, 3));

                tb.Cells[1, 4].TextString = "Bearing\\P plinth No."; //获取i行j列数据
                tb.Cells[1, 4].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 4].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 4].Contents[0].Rotation = 0;
                tb.Cells[1, 4].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 4].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 4, 3, 4));

                tb.Cells[1, 5].TextString = "B"; //获取i行j列数据
                tb.Cells[1, 5].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 5].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 5].Contents[0].Rotation = 0;
                tb.Cells[1, 5].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 5].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 5, 1, 6));

                tb.Cells[2, 2].TextString = "Coordinates (m)"; //获取i行j列数据
                tb.Cells[2, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 2].Contents[0].Rotation = 0;
                tb.Cells[2, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 2].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 2, 2, 3));

                tb.Cells[2, 5].TextString = "Coordinates (m)"; //获取i行j列数据
                tb.Cells[2, 5].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 5].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 5].Contents[0].Rotation = 0;
                tb.Cells[2, 5].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 5].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 5, 2, 6));

                tb.Cells[3, 2].TextString = "N."; //获取i行j列数据
                tb.Cells[3, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 2].Contents[0].Rotation = 0;
                tb.Cells[3, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 2].Contents[0].TextStyleId = id;

                tb.Cells[3, 3].TextString = "E."; //获取i行j列数据
                tb.Cells[3, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 3].Contents[0].Rotation = 0;
                tb.Cells[3, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 3].Contents[0].TextStyleId = id;


                tb.Cells[3, 5].TextString = "N."; //获取i行j列数据
                tb.Cells[3, 5].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 5].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 5].Contents[0].Rotation = 0;
                tb.Cells[3, 5].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 5].Contents[0].TextStyleId = id;

                tb.Cells[3, 6].TextString = "E."; //获取i行j列数据
                tb.Cells[3, 6].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 6].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 6].Contents[0].Rotation = 0;
                tb.Cells[3, 6].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 6].Contents[0].TextStyleId = id;

                for (int i = 0; i < tCount ; i++)
                {
                    //A
                    if (i < tbAValue.Rows.Count)
                    {
                        tb.Cells[4 + i, 1].TextString = tbAValue.Rows[i]["PlinthNo"].ToString().Replace("月","-").Replace("日", ""); //获取i行j列数据
                        tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[i]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                    }
                    else
                    {
                        tb.Cells[4 + i, 1].TextString = " "; //获取i行j列数据
                        tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 2].TextString = " "; //获取i行j列数据
                        tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 3].TextString = " "; //获取i行j列数据
                        tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                    }

                    //B
                    if (i < tbBValue.Rows.Count)
                    {
                        tb.Cells[4 + i, 4].TextString = tbBValue.Rows[i]["PlinthNo"].ToString().Replace("月", "-").Replace("日", "");//获取i行j列数据
                        tb.Cells[4 + i, 4].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 4].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 4].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 4].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 4].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 5].TextString = double.Parse(tbBValue.Rows[i]["North"].ToString()).ToString("0.000");  //获取i行j列数据
                        tb.Cells[4 + i, 5].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 5].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 5].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 5].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 5].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 6].TextString = double.Parse(tbBValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 6].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 6].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 6].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 6].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 6].Contents[0].TextStyleId = id;
                    }
                    else
                    {
                        tb.Cells[4 + i, 4].TextString =" ";//获取i行j列数据
                        tb.Cells[4 + i, 4].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 4].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 4].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 4].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 4].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 5].TextString = " ";  //获取i行j列数据
                        tb.Cells[4 + i, 5].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 5].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 5].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 5].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 5].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 6].TextString = " "; //获取i行j列数据
                        tb.Cells[4 + i, 6].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 6].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 6].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 6].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 6].Contents[0].TextStyleId = id;
                    }
                }

                tb.Layer = "细线";
                tb.LineWeight = LineWeight.LineWeight013;
                tb.ColorIndex = 4;
                modelSpace.AppendEntity(tb);
                tr.AddNewlyCreatedDBObject(tb, true);
                ext = ext.Add(new Extents2d(tb.Bounds.Value.MinPoint.Convert2D(), tb.Bounds.Value.MaxPoint.Convert2D()));

                #endregion





                #region  边框粗线设置
                List<Point2d> pList = new List<Point2d>();
                Point2d pt1 = startPoint.Convert2D();
                pList.Add(pt1);
                Point2d pt2 = pt1.Convert2D(0, -tb.Height);
                pList.Add(pt2);
                Point2d pt3 = pt1.Convert2D(tb.Width, -tb.Height);
                pList.Add(pt3);
                Point2d pt4 = pt1.Convert2D(tb.Width, 0);
                pList.Add(pt4);
                PolylinePloter.AddPolylineByList(db, ref ext, pList, "粗线", 2);
                #endregion
                string _blcName = "Model1";
                db.CopyBlockFromFile(_dwgPath, _blcName);

                BlockTool.InsertBlockReference(pt4.Convert3D(45, 10), 1, _blcName, _dwgPath, ref ext, 0);

                _blcName = "RampModel2";
                db.CopyBlockFromFile(_dwgPath, _blcName);
                Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
                Dictionary<string, string> dic = new Dictionary<string, string>();
                int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(pierName, @"[^0-9]+", "").ToString());
                string stN = pierName.Replace(pierNo.ToString(), "") + (pierNo - 1);
                string edN = pierName.Replace(pierNo.ToString(), "") + (pierNo + 1);

                dic.Add(stN, "string");
                dicA.Add("NOS", dic);

                dic = new Dictionary<string, string>();
                dic.Add(edN, "string");
                dicA.Add("NOE", dic);

                BlockTool.InsertBlockReference(pt4.Convert3D(20, -130), 1, _blcName, _dwgPath, dicA, null, ref ext);

                //BlockTool.InsertBlockReference(pt4.Convert3D(45, -90), 1, _blcName, _dwgPath, ref ext, 0);
                Point2d pNote = pt2.Convert2D(0, -2);



                tr.Commit();
                return tb;
            }
        }

        /// <summary>
        /// 垫石厚度绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="scale"></param>
        /// <param name="dwgPath"></param>
        public static void DrawPlinthDepthTable(Database db, double scale, string dwgPath ,string filepath,string pierPara, ref string pierdiv, string title = "MAINLINE",string tkPath="")
        {
            Extents2d ext = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d ext1 = new Extents2d(Point2d.Origin, Point2d.Origin);
            Point2d CT = Point2d.Origin.Convert2D(0, -2 * scale);
            Point2d M1 = CT;
            ext = new Extents2d(M1, M1);
            System.Data.DataTable dtA = new System.Data.DataTable();
            System.Data.DataTable dtB = new System.Data.DataTable();
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WeChat Files\wxid_1fmp3vdht5sl22\FileStorage\File\2021-12\P266-P294垫石坐标+高程.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani垫石坐标.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-2 垫石坐标(1).csv");
            System.Data.DataTable dt;// = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-1 垫石坐标.csv");
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filepath);
            if (fileInfo.Extension.Contains("xlsx"))
                dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
            else
                dt = FDEECommonTools.CVSTools.OpenCSV(filepath);

            DataView dv0 = dt.DefaultView;
            dt = dv0.ToTable(true, new string[] { "Pier", "Side", "PlinthNo", "East", "North", "Height", "H0" });

            System.Data.DataTable dtP = new System.Data.DataTable();
            DataView dv = dt.DefaultView;

            dtP = dv.ToTable(true, new string[] { "Pier" });
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-292' and Pier<=" + "'P-299'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-300' and Pier<=" + "'P-307'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-308' and Pier<=" + "'P-315'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-316' and Pier<=" + "'P-322'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-323' and Pier<=" + "'P-329'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'P-330' and Pier<=" + "'P-335'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'RP-11' and Pier<=" + "'RP-14'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'RP-15' and Pier<=" + "'RP-17'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'RP-18' and Pier<=" + "'RP-21'");
            //DataRow[] rows = dtP.Select("Pier>=" + "'RP-06' and Pier<=" + "'RP-08'");
            string[] pierL = pierPara.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(',');
            DataRow[] rows;
            if (pierL.Length>=1&& !string.IsNullOrWhiteSpace(pierL[0]))
            {
                string s = "";
               for(int i=0;i< pierL.Length;i++)
                {
                    if (string.IsNullOrWhiteSpace(s))
                        s = "'" + pierL[i] + "'";
                    else
                        s += ",'" + pierL[i] + "'";
                }
                rows = dtP.Select("Pier in (" + s+")");
            }
            else
              rows = dtP.Select();
            if (rows.Length > 0)
            {
                pierdiv = rows[0][0].ToString()+"-"+ rows[rows.Length - 1][0].ToString();
                int pageno = rows.Length / 4;
                if (pageno < rows.Length / 4.0)
                {
                    pageno += 1;
                }
                for (int i = 0; i < pageno; i++)
                {
                    string stpierName = rows[i * 4][0].ToString();
                    string endpierName = "";
                    int count = 4;
                    if (i < pageno - 1)
                        endpierName = rows[i * 4 + 3][0].ToString();
                    else
                    {
                        endpierName = rows[rows.Length - 1][0].ToString();
                        count = rows.Length - i * 4;
                    }
                    int columnCount = 1;
                    List<string> pierLst = new List<string>();
                    for (int j = i * 4; j < i * 4 + count; j++)
                    {

                        DataRow dr = rows[j];
                        string pierName = dr[0].ToString();
                        pierLst.Add(pierName);
                        DataRow[] drsA = dt.Select("Pier='" + dr[0] + "' and Side='A'");
                        dtA = dt.Clone();
                        if (drsA.Length > 0)
                        {
                            foreach (DataRow item in drsA)
                            {
                                dtA.ImportRow(item);
                            }
                        }
                        if (dtA.Rows.Count / 4 > columnCount)
                            columnCount = dtA.Rows.Count / 4;
                        DataRow[] drsB = dt.Select("Pier='" + dr[0] + "' and Side='B'");
                        dtB = dt.Clone();
                        if (drsB.Length > 0)
                        {
                            foreach (DataRow item in drsB)
                            {
                                dtB.ImportRow(item);
                            }
                        }
                        if (dtB.Rows.Count / 4 > columnCount)
                            columnCount = dtB.Rows.Count / 4;
                    }
                    Table lasTb = new Table();
                    //string title = "MAINLINE";//修改
                    //string title = "RAMP BANANI EX-2";//修改
                    //string title = "RAMP BANANI EX-1";//修改
                    ext = new Extents2d(M1.Convert2D(0, -297 * i), M1.Convert2D(0, -297 * i));
                    lasTb = DrawingPlinthDepthTable(db, ref ext, M1.Convert3D(0, -297 * i),
                        Extensions.curFont, scale, dt, dwgPath, stpierName, endpierName, pierLst, columnCount, title);

                    if (lasTb != null)
                    {
                        double width = lasTb.Width;
                        string str1 = string.Format("INFORMATION SHEET OF BEARING PLINTH FOR '{0}' TO '{1}' OF {2}", stpierName, endpierName, title);
                        string str2 = "";
                        TextPloter.PrintScaleDoubleSideText(db, M1.Convert2D(0, -297 * i).Convert2D(width * 0.5, 8 * scale), 3, str1, str2, ref ext, scale, Extensions.curFont);
                    }
                    Common.CreateLayoutNew(db, "PlinthDepth", ext, scale, 1, i, 0,false, tkPath);
                }
            }
            #region 
            //if (dtP.Rows.Count > 0)
            //{
            //    int pageno = dtP.Rows.Count / 4;
            //    if (pageno < dtP.Rows.Count / 4.0)
            //    {
            //        pageno += 1;
            //    }
            //    for (int i = 0; i < pageno; i++)
            //    {
            //        string stpierName = dtP.Rows[i * 4][0].ToString();
            //        string endpierName = "";
            //        int count = 4;
            //        if (i < pageno - 1)
            //            endpierName = dtP.Rows[i * 4 + 3][0].ToString();
            //        else
            //        {
            //            endpierName = dtP.Rows[dtP.Rows.Count - 1][0].ToString();
            //            count = dtP.Rows.Count - i * 4;
            //        }
            //        int columnCount = 1;
            //        List<string> pierLst = new List<string>();
            //        for (int j = i * 4; j < i * 4 + count; j++)
            //        {

            //            DataRow dr = dtP.Rows[j];
            //            string pierName = dr[0].ToString();
            //            pierLst.Add(pierName);
            //            DataRow[] drsA = dt.Select("Pier='" + dr[0] + "' and Side='A'");
            //            dtA = dt.Clone();
            //            if (drsA.Length > 0)
            //            {
            //                foreach (DataRow item in drsA)
            //                {
            //                    dtA.ImportRow(item);
            //                }
            //            }
            //            if (dtA.Rows.Count / 4 > columnCount)
            //                columnCount = dtA.Rows.Count / 4;
            //            DataRow[] drsB = dt.Select("Pier='" + dr[0] + "' and Side='B'");
            //            dtB = dt.Clone();
            //            if (drsB.Length > 0)
            //            {
            //                foreach (DataRow item in drsB)
            //                {
            //                    dtB.ImportRow(item);
            //                }
            //            }
            //            if (dtB.Rows.Count / 4 > columnCount)
            //                columnCount = dtB.Rows.Count / 4;
            //        }
            //        Table lasTb = new Table();

            //        ext = new Extents2d(M1.Convert2D(0, -297 * i), M1.Convert2D(0, -297 * i));
            //        lasTb = DrawingPlinthDepthTable(db, ref ext, M1.Convert3D(0, -297 * i),
            //            Extensions.curFont, scale, dt, dwgPath, stpierName, endpierName, pierLst, columnCount);

            //        if (lasTb != null)
            //        {
            //            double width = lasTb.Width;
            //            string str1 = string.Format("INFORMATION SHEET OF BEARING PLINTH FOR '{0}' TO '{1}' OF MAINLINE", stpierName, endpierName);
            //            string str2 = "";
            //            TextPloter.PrintScaleDoubleSideText(db, M1.Convert2D(0, -297 * i).Convert2D(width * 0.5, 8 * scale), 3, str1, str2, ref ext, scale, Extensions.curFont);
            //        }
            //        Common.CreateLayoutNew(db, "PlinthDepth", ext, scale, 1, i, 0);
            //    }
            //}
            #endregion


        }

        /// <summary>
        /// 垫石厚度表格绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="startPoint"></param>
        /// <param name="txtStyle"></param>
        /// <param name="scale"></param>
        /// <param name="dt"></param>
        /// <param name="_dwgPath"></param>
        /// <param name="stNo"></param>
        /// <param name="endNo"></param>
        /// <param name="pierL"></param>
        /// <param name="columnCount"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static Table DrawingPlinthDepthTable(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataTable dt, string _dwgPath, string stNo, string endNo, List<string> pierL, int columnCount, string title = "MAINLINE")
        {

            System.Data.DataTable tbAValue = new System.Data.DataTable();
            System.Data.DataTable tbBValue = new System.Data.DataTable();
            string pierName = "";
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                ObjectId id;
                TextStyleTable st = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                id = st[txtStyle];

                int rowNum = pierL.Count * 6 + 2;

                Table tb = new Table();
                #region  表格

                startPoint = startPoint.Convert3D();
                tb = new Table();
                int colNum = 4 + columnCount;
                tb.SetSize(rowNum, colNum);       // 设置几行几列
                tb.Position = startPoint;
                tb.GenerateLayout();

                #region 设置列宽
                // 设置列宽
                for (int i = 0; i < colNum; ++i)
                {
                    if (colNum < 18)
                    {
                        if (i == 3)
                            tb.Columns[i].Width = 15 * 3 * scale;
                        else
                            tb.Columns[i].Width = 6 * 3 * scale;
                    }
                    else
                    {
                        if (i == 3)
                            tb.Columns[i].Width = 15 * 3 * scale;
                        else if (i > 3)
                            tb.Columns[i].Width = 4.8 * 3 * scale;
                        else
                            tb.Columns[i].Width = 4.8 * 3 * scale;
                    }
                }

                //for (int i = 0; i < colNum; ++i)
                //{
                //    if (i < 3)
                //        tb.Columns[i].Width = 3.3 * 3 * scale;
                //    if (i == 3)
                //        tb.Columns[i].Width = 15 * 3 * scale;
                //    else
                //        tb.Columns[i].Width = 4.9 * 3 * scale;
                //}

                //行高
                for (int i = 0; i < rowNum; ++i)
                {
                    tb.Rows[i].Height = 6 * scale;
                }
                #endregion


                tb.Cells[0, 0].TextString = "Location"; //获取i行j列数据
                tb.Cells[0, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 0].Contents[0].Rotation = 0;
                tb.Cells[0, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0));

                tb.Cells[0, 1].TextString = "Pier No."; //获取i行j列数据
                tb.Cells[0, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 1].Contents[0].Rotation = 0;
                tb.Cells[0, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 1].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 1, 1, 1));


                tb.Cells[0, 2].TextString = "Station"; //获取i行j列数据
                tb.Cells[0, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 2].Contents[0].Rotation = 0;
                tb.Cells[0, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 2].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 2, 1, 2));

                tb.Cells[0, 3].TextString = "Parameter"; //获取i行j列数据
                tb.Cells[0, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 3].Contents[0].Rotation = 0;
                tb.Cells[0, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 3].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 3, 1, 3));

                tb.Cells[0, 4].TextString = "Bearing Plinth No."; //获取i行j列数据
                tb.Cells[0, 4].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 4].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 4].Contents[0].Rotation = 0;
                tb.Cells[0, 4].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 4].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 4, 0, colNum - 1));


                tb.Cells[2, 0].TextString = title;// "MAINLINE"; //获取i行j列数据
                tb.Cells[2, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 0].Contents[0].Rotation = 0;
                tb.Cells[2, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 0, rowNum - 1, 0));

                for (int c = 4; c < colNum; c++)
                {
                    tb.Cells[1, c].TextString = (c - 3).ToString(); //获取i行j列数据
                    tb.Cells[1, c].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[1, c].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[1, c].Contents[0].Rotation = 0;
                    tb.Cells[1, c].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[1, c].Contents[0].TextStyleId = id;
                }

                for (int i = 0; i < pierL.Count; i++)
                {
                    string no = pierL[i];
                    tb.Cells[i * 6 + 2, 1].TextString = no; //获取i行j列数据
                    tb.Cells[i * 6 + 2, 1].Contents[0].TextHeight = 2 * scale;
                    tb.Cells[i * 6 + 2, 1].Alignment = CellAlignment.MiddleCenter;
                    tb.Cells[i * 6 + 2, 1].Contents[0].Rotation = 0;
                    tb.Cells[i * 6 + 2, 1].Borders.Horizontal.Margin = 1 * scale;
                    tb.Cells[i * 6 + 2, 1].Contents[0].TextStyleId = id;
                    tb.MergeCells(CellRange.Create(tb, i * 6 + 2, 1, i * 6 + 7, 1));

                    DataRow[] drsA = dt.Select("Pier='" + no + "' and Side='A' and (PlinthNo like '%-1' or PlinthNo like '%月1日'  or  PlinthNo like '1月13日' or  PlinthNo like '1月14日' or  PlinthNo like '1月15日' or  PlinthNo like '1月16日' or  PlinthNo like '1月17日' or  PlinthNo like '1月18日' or  PlinthNo like '1月19日' or  PlinthNo like '1月20日')");

                    if (drsA.Length > 0)
                    {
                        tb.Cells[i * 6 + 2, 2].TextString = "A"; //获取i行j列数据
                        tb.Cells[i * 6 + 2, 2].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 2, 2].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 2, 2].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 2, 2].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 2, 2].Contents[0].TextStyleId = id;
                        tb.MergeCells(CellRange.Create(tb, i * 6 + 2, 2, i * 6 + 4, 2));

                        tb.Cells[i * 6 + 2, 3].TextString = "Thickness of Bearing Plinth(m)"; //获取i行j列数据
                        tb.Cells[i * 6 + 2, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 2, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 2, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 2, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 2, 3].Contents[0].TextStyleId = id;

                        tb.Cells[i * 6 + 3, 3].TextString = "Elevation at top of Bearing Plinth(MSL/m)"; //获取i行j列数据
                        tb.Cells[i * 6 + 3, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 3, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 3, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 3, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 3, 3].Contents[0].TextStyleId = id;

                        tb.Cells[i * 6 + 4, 3].TextString = "Type of Bearing Plinth"; //获取i行j列数据
                        tb.Cells[i * 6 + 4, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 4, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 4, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 4, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 4, 3].Contents[0].TextStyleId = id;

                        for (int m = 0; m < drsA.Length; m++)
                        {
                            tb.Cells[i * 6 + 2, 4 + m].TextString = double.Parse(drsA[m]["Height"].ToString()).ToString("0.000"); //获取i行j列数据
                            tb.Cells[i * 6 + 2, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 2, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 2, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 2, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 2, 4 + m].Contents[0].TextStyleId = id;

                            tb.Cells[i * 6 + 3, 4 + m].TextString = double.Parse(drsA[m]["H0"].ToString()).ToString("0.000"); //获取i行j列数据
                            tb.Cells[i * 6 + 3, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 3, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 3, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 3, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 3, 4 + m].Contents[0].TextStyleId = id;
                            double U2 = double.Parse(drsA[m]["Height"].ToString());
                            string type = "TYPE 1";
                            if (U2 <= 0.04) type = "TYPE 1";
                            else if (U2 <= 0.1) type = "TYPE 2A";
                            else if (U2 <= 0.3) type = "TYPE 2B";
                            else if (U2 <= 0.5) type = "TYPE 2C";
                            else if (U2 <= 0.7) type = "TYPE3A";
                            else if (U2 <= 0.9) type = "TYPE3B";
                            else if (U2 <= 1) type = "TYPE3C";
                            else if (U2 <= 1.2) type = "TYPE4A";
                            else if (U2 <= 1.4) type = "TYPE4B";
                            else if (U2 <= 1.6) type = "TYPE4C";
                            else type = " ";

                            tb.Cells[i * 6 + 4, 4 + m].TextString = type; //获取i行j列数据
                            tb.Cells[i * 6 + 4, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 4, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 4, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 4, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 4, 4 + m].Contents[0].TextStyleId = id;
                        }
                    }

                    DataRow[] drsB = dt.Select("Pier='" + no + "' and Side='B' and (PlinthNo like '%-1' or PlinthNo like '%月1日'  or  PlinthNo like '1月13日' or  PlinthNo like '1月14日' or  PlinthNo like '1月15日' or  PlinthNo like '1月16日' or  PlinthNo like '1月17日' or  PlinthNo like '1月18日' or  PlinthNo like '1月19日' or  PlinthNo like '1月20日')");

                    if (drsB.Length > 0)
                    {
                        tb.Cells[i * 6 + 5, 2].TextString = "B"; //获取i行j列数据
                        tb.Cells[i * 6 + 5, 2].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 5, 2].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 5, 2].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 5, 2].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 5, 2].Contents[0].TextStyleId = id;
                        tb.MergeCells(CellRange.Create(tb, i * 6 + 5, 2, i * 6 + 7, 2));

                        tb.Cells[i * 6 + 5, 3].TextString = "Thickness of Bearing Plinth(m)"; //获取i行j列数据
                        tb.Cells[i * 6 + 5, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 5, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 5, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 5, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 5, 3].Contents[0].TextStyleId = id;

                        tb.Cells[i * 6 + 6, 3].TextString = "Elevation at top of Bearing Plinth(MSL/m)"; //获取i行j列数据
                        tb.Cells[i * 6 + 6, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 6, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 6, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 6, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 6, 3].Contents[0].TextStyleId = id;

                        tb.Cells[i * 6 + 7, 3].TextString = "Type of Bearing Plinth"; //获取i行j列数据
                        tb.Cells[i * 6 + 7, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 6 + 7, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 6 + 7, 3].Contents[0].Rotation = 0;
                        tb.Cells[i * 6 + 7, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 6 + 7, 3].Contents[0].TextStyleId = id;

                        for (int m = 0; m < drsB.Length; m++)
                        {
                            tb.Cells[i * 6 + 5, 4 + m].TextString = double.Parse(drsB[m]["Height"].ToString()).ToString("0.000"); //获取i行j列数据
                            tb.Cells[i * 6 + 5, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 5, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 5, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 5, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 5, 4 + m].Contents[0].TextStyleId = id;

                            tb.Cells[i * 6 + 6, 4 + m].TextString = double.Parse(drsB[m]["H0"].ToString()).ToString("0.000"); //获取i行j列数据
                            tb.Cells[i * 6 + 6, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 6, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 6, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 6, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 6, 4 + m].Contents[0].TextStyleId = id;
                            double U2 = double.Parse(drsB[m]["Height"].ToString());
                            string type = "TYPE 1";
                            if (U2 <= 0.04) type = "TYPE 1";
                            else if (U2 <= 0.1) type = "TYPE 2A";
                            else if (U2 <= 0.3) type = "TYPE 2B";
                            else if (U2 <= 0.5) type = "TYPE 2C";
                            else if (U2 <= 0.7) type = "TYPE3A";
                            else if (U2 <= 0.9) type = "TYPE3B";
                            else if (U2 <= 1) type = "TYPE3C";
                            else if (U2 <= 1.2) type = "TYPE4A";
                            else if (U2 <= 1.4) type = "TYPE4B";
                            else if (U2 <= 1.6) type = "TYPE4C";
                            else type = " ";

                            tb.Cells[i * 6 + 7, 4 + m].TextString = type; //获取i行j列数据
                            tb.Cells[i * 6 + 7, 4 + m].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 6 + 7, 4 + m].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 6 + 7, 4 + m].Contents[0].Rotation = 0;
                            tb.Cells[i * 6 + 7, 4 + m].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 6 + 7, 4 + m].Contents[0].TextStyleId = id;
                        }
                    }
                }

                //if (n == 0)
                //{
                //    for (int i = 0; i < halfNum * 4; i++)
                //    {
                //        //A
                //        if (i < tbAValue.Rows.Count)
                //        {
                //            tb.Cells[4 + i, 1].TextString = tbAValue.Rows[i]["PlinthNo"].ToString(); //获取i行j列数据
                //            tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                //            tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[i]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                //            tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                //            tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                //            tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                //        }


                //    }
                //}
                //else
                //{
                //    for (int m = halfNum * 4; m < 44; m++)
                //    {
                //        int i = m - halfNum * 4;                           
                //        //A
                //        if (m < tbAValue.Rows.Count)
                //        {
                //            tb.Cells[4 + i, 1].TextString = tbAValue.Rows[m]["PlinthNo"].ToString(); //获取i行j列数据
                //            tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                //            tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[m]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                //            tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                //            tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[m]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                //            tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                //            tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                //            tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                //            tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                //            tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                //        }


                //    }
                //}

                tb.Layer = "细线";
                tb.LineWeight = LineWeight.LineWeight013;
                tb.ColorIndex = 4;
                modelSpace.AppendEntity(tb);
                tr.AddNewlyCreatedDBObject(tb, true);
                ext = ext.Add(new Extents2d(tb.Bounds.Value.MinPoint.Convert2D(), tb.Bounds.Value.MaxPoint.Convert2D()));

                #endregion



                #region  边框粗线设置
                List<Point2d> pList = new List<Point2d>();
                Point2d pt1 = startPoint.Convert2D();
                pList.Add(pt1);
                Point2d pt2 = pt1.Convert2D(0, -tb.Height);
                pList.Add(pt2);
                Point2d pt3 = pt1.Convert2D(tb.Width, -tb.Height);
                pList.Add(pt3);
                Point2d pt4 = pt1.Convert2D(tb.Width, 0);
                pList.Add(pt4);
                PolylinePloter.AddPolylineByList(db, ref ext, pList, "粗线", 2);
                #endregion
                //string _blcName = "Model1";
                //db.CopyBlockFromFile(_dwgPath, _blcName);

                //BlockTool.InsertBlockReference(pt4.Convert3D(45, -10), 1, _blcName, _dwgPath, ref ext, 0);

                string _blcName = "Model2";
                if (title != "MAINLINE")
                    _blcName = "RampModel2";
                db.CopyBlockFromFile(_dwgPath, _blcName);
                Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
                Dictionary<string, string> dic = new Dictionary<string, string>();


                dic.Add(stNo, "string");
                dicA.Add("NOS", dic);

                dic = new Dictionary<string, string>();
                dic.Add(endNo, "string");
                dicA.Add("NOE", dic);

                dic = new Dictionary<string, string>();
                dic.Add("A", "string");
                dicA.Add("A", dic);

                dic = new Dictionary<string, string>();
                dic.Add("B", "string");
                dicA.Add("B", dic);

                //BlockTool.InsertBlockReference(pt4.Convert3D(20, -tb.Height*0.5-36), 1, _blcName, _dwgPath, dicA, null, ref ext);
                BlockTool.InsertBlockReference(pt2.Convert3D(tb.Width * 0.5 - 32, -75), 1, _blcName, _dwgPath, dicA, null, ref ext);
                //BlockTool.InsertBlockReference(pt4.Convert3D(45, -90), 1, _blcName, _dwgPath, ref ext, 0);
                Point2d pNote = pt2.Convert2D(0, -2);



                tr.Commit();
                return tb;
            }
        }

        #region 暂时无数据
        /// <summary>
        /// 挡板坐标绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="scale"></param>
        /// <param name="dwgPath"></param>
        public static void DrawPlinthBlockTable(Database db, double scale, string dwgPath)
        {
            Extents2d ext = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d ext1 = new Extents2d(Point2d.Origin, Point2d.Origin);
            Point2d CT = Point2d.Origin.Convert2D(0, -2 * scale);
            Point2d M1 = CT;
            ext = new Extents2d(M1, M1);
            System.Data.DataTable dtA = new System.Data.DataTable();
            System.Data.DataTable dtB = new System.Data.DataTable();
            System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688853201596598\Cache\File\2021-10\P266-P291垫石坐标+高程.csv");


            DataView dv0 = dt.DefaultView;
            dt = dv0.ToTable(true, new string[] { "Pier", "Side", "PlinthNo", "East", "North" });

            System.Data.DataTable dtP = new System.Data.DataTable();
            DataView dv = dt.DefaultView;
            dtP = dv.ToTable(true, new string[] { "Pier" });
            if (dtP.Rows.Count > 0)
            {
                for (int i = 0; i < dtP.Rows.Count; i++)
                {

                    DataRow dr = dtP.Rows[i];
                    string pierName = dr[0].ToString();
                    DataRow[] drsA = dt.Select("Pier='" + dr[0] + "' and Side='A'");
                    dtA = dt.Clone();
                    if (drsA.Length > 0)
                    {
                        foreach (DataRow item in drsA)
                        {
                            dtA.ImportRow(item);
                        }
                    }
                    DataRow[] drsB = dt.Select("Pier='" + dr[0] + "' and Side='B'");
                    dtB = dt.Clone();
                    if (drsB.Length > 0)
                    {
                        foreach (DataRow item in drsB)
                        {
                            dtB.ImportRow(item);
                        }
                    }
                    string title = "MAINLINE";//修改

                    Table lasTb = new Table();
                    ext = new Extents2d(M1.Convert2D(0, -297 * i), M1.Convert2D(0, -297 * i));
                    lasTb = DrawingPlinthBlockTable(db, ref ext, M1.Convert3D(0, -297 * i),
                        Extensions.curFont, scale, dtA, dtB, pierName, dwgPath);
                    double width = 0;
                    double height = 0;
                    if (lasTb != null)
                    {
                        string str1 = string.Format("COORDINATES OF BUFFER FOR '{0}' OF {1}", pierName, title);
                        string str2 = "";
                        TextPloter.PrintScaleDoubleSideText(db, M1.Convert2D(0, -297 * i).Convert2D(width / 2, 8 * scale), 3, str1, str2, ref ext, scale, Extensions.curFont);
                    }
                    Common.CreateLayoutNew(db, "挡板坐标数据表", ext, scale, 1, i, 0);
                }

            }
        }
        /// <summary>
        /// 挡板坐标表格绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="startPoint"></param>
        /// <param name="txtStyle"></param>
        /// <param name="scale"></param>
        /// <param name="tbAValue"></param>
        /// <param name="tbBValue"></param>
        /// <param name="pierName"></param>
        /// <param name="_dwgPath"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public static Table DrawingPlinthBlockTable(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataTable tbAValue, System.Data.DataTable tbBValue, string pierName, string _dwgPath, string title = "MAINLINE")
        {


            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                ObjectId id;
                TextStyleTable st = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                id = st[txtStyle];

                int tCount = 0;
                if (tbAValue.Rows.Count > tbBValue.Rows.Count)
                    tCount = tbAValue.Rows.Count;
                else
                    tCount = tbBValue.Rows.Count;
                int rowNum = tCount + 4;


                Table tb = new Table();
                #region  表格

                startPoint = startPoint.Convert3D(tb.Width);
                tb = new Table();
                int colNum = 8;
                tb.SetSize(rowNum, colNum);       // 设置几行几列
                tb.Position = startPoint;
                tb.GenerateLayout();

                #region 设置列宽
                // 设置列宽
                for (int i = 0; i < colNum; ++i)
                {
                    tb.Columns[i].Width = 6 * 3 * scale;
                }


                //行高
                for (int i = 0; i < rowNum; ++i)
                {
                    tb.Rows[i].Height = 9 * scale;
                }
                #endregion


                tb.Cells[0, 0].TextString = "Location"; //获取i行j列数据
                tb.Cells[0, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 0].Contents[0].Rotation = 0;
                tb.Cells[0, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 0, 4, 0));

                tb.Cells[0, 1].TextString = pierName; //获取i行j列数据
                tb.Cells[0, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 1].Contents[0].Rotation = 0;
                tb.Cells[0, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 1].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 0, 1, 0, 7));


                tb.Cells[2, 0].TextString = title;// "MAINLINE"; //获取i行j列数据
                tb.Cells[2, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 0].Contents[0].Rotation = 0;
                tb.Cells[2, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 0].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 5, 0, rowNum - 1, 0));

                tb.Cells[1, 1].TextString = "Pier No."; //获取i行j列数据
                tb.Cells[1, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 1].Contents[0].Rotation = 0;
                tb.Cells[1, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 1].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 1, 3, 1));

                tb.Cells[1, 2].TextString = "Concrete\\P Buffer No."; //获取i行j列数据
                tb.Cells[1, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 2].Contents[0].Rotation = 0;
                tb.Cells[1, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 2].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 2, 3, 2));

                tb.Cells[1, 3].TextString = "A"; //获取i行j列数据
                tb.Cells[1, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 3].Contents[0].Rotation = 0;
                tb.Cells[1, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 3].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 3, 1, 4));

                tb.Cells[1, 5].TextString = "Concrete\\P Buffer No."; //获取i行j列数据
                tb.Cells[1, 5].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 5].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 5].Contents[0].Rotation = 0;
                tb.Cells[1, 5].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 5].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 5, 3, 5));

                tb.Cells[1, 6].TextString = "B"; //获取i行j列数据
                tb.Cells[1, 6].Contents[0].TextHeight = 2 * scale;
                tb.Cells[1, 6].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[1, 6].Contents[0].Rotation = 0;
                tb.Cells[1, 6].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[1, 6].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 1, 6, 1, 7));

                tb.Cells[2, 3].TextString = "Coordinates (m)"; //获取i行j列数据
                tb.Cells[2, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 3].Contents[0].Rotation = 0;
                tb.Cells[2, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 3].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 3, 2, 4));

                tb.Cells[2, 6].TextString = "Coordinates (m)"; //获取i行j列数据
                tb.Cells[2, 6].Contents[0].TextHeight = 2 * scale;
                tb.Cells[2, 6].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[2, 6].Contents[0].Rotation = 0;
                tb.Cells[2, 6].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[2, 6].Contents[0].TextStyleId = id;
                tb.MergeCells(CellRange.Create(tb, 2, 6, 2, 7));

                tb.Cells[3, 3].TextString = "N."; //获取i行j列数据
                tb.Cells[3, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 3].Contents[0].Rotation = 0;
                tb.Cells[3, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 3].Contents[0].TextStyleId = id;

                tb.Cells[3, 4].TextString = "E."; //获取i行j列数据
                tb.Cells[3, 4].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 4].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 4].Contents[0].Rotation = 0;
                tb.Cells[3, 4].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 4].Contents[0].TextStyleId = id;


                tb.Cells[3, 6].TextString = "N."; //获取i行j列数据
                tb.Cells[3, 6].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 6].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 6].Contents[0].Rotation = 0;
                tb.Cells[3, 6].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 6].Contents[0].TextStyleId = id;

                tb.Cells[3, 7].TextString = "E."; //获取i行j列数据
                tb.Cells[3, 7].Contents[0].TextHeight = 2 * scale;
                tb.Cells[3, 7].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[3, 7].Contents[0].Rotation = 0;
                tb.Cells[3, 7].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[3, 7].Contents[0].TextStyleId = id;

                for (int i = 0; i < tCount; i++)
                {
                    //A
                    if (i < tbAValue.Rows.Count)
                    {
                        tb.Cells[4 + i, 1].TextString = tbAValue.Rows[i]["PlinthNo"].ToString(); //获取i行j列数据
                        tb.Cells[4 + i, 1].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 1].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 1].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 1].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 1].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 2].TextString = double.Parse(tbAValue.Rows[i]["North"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 2].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 2].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 2].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 2].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 2].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 3].TextString = double.Parse(tbAValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 3].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 3].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 3].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 3].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 3].Contents[0].TextStyleId = id;
                    }

                    //B
                    if (i < tbBValue.Rows.Count)
                    {
                        tb.Cells[4 + i, 4].TextString = tbBValue.Rows[i]["PlinthNo"].ToString();//获取i行j列数据
                        tb.Cells[4 + i, 4].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 4].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 4].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 4].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 4].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 5].TextString = double.Parse(tbBValue.Rows[i]["North"].ToString()).ToString("0.000");  //获取i行j列数据
                        tb.Cells[4 + i, 5].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 5].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 5].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 5].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 5].Contents[0].TextStyleId = id;

                        tb.Cells[4 + i, 6].TextString = double.Parse(tbBValue.Rows[i]["East"].ToString()).ToString("0.000"); //获取i行j列数据
                        tb.Cells[4 + i, 6].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[4 + i, 6].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[4 + i, 6].Contents[0].Rotation = 0;
                        tb.Cells[4 + i, 6].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[4 + i, 6].Contents[0].TextStyleId = id;
                    }
                }


                tb.Layer = "细线";
                tb.LineWeight = LineWeight.LineWeight013;
                tb.ColorIndex = 4;
                modelSpace.AppendEntity(tb);
                tr.AddNewlyCreatedDBObject(tb, true);
                ext = ext.Add(new Extents2d(tb.Bounds.Value.MinPoint.Convert2D(), tb.Bounds.Value.MaxPoint.Convert2D()));

                #endregion




                #region  边框粗线设置
                List<Point2d> pList = new List<Point2d>();
                Point2d pt1 = startPoint.Convert2D(-tb.Width);
                pList.Add(pt1);
                Point2d pt2 = pt1.Convert2D(0, -tb.Height);
                pList.Add(pt2);
                Point2d pt3 = pt1.Convert2D(tb.Width * 2, -tb.Height);
                pList.Add(pt3);
                Point2d pt4 = pt1.Convert2D(tb.Width * 2, 0);
                pList.Add(pt4);
                PolylinePloter.AddPolylineByList(db, ref ext, pList, "粗线", 2);
                #endregion
                string _blcName = "buffer1";
                db.CopyBlockFromFile(_dwgPath, _blcName);

                BlockTool.InsertBlockReference(pt4.Convert3D(45, -10), 1, _blcName, _dwgPath, ref ext, 0);

                _blcName = "buffer2";
                db.CopyBlockFromFile(_dwgPath, _blcName);
                Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
                Dictionary<string, string> dic = new Dictionary<string, string>();
                //int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(pierName, @"[^0-9]+", "").ToString());
                ////string stN = pierName.Replace(pierNo.ToString(), "") + (pierNo - 1);
                ////string edN = pierName.Replace(pierNo.ToString(), "") + (pierNo + 1);

                dic.Add(pierName, "string");
                dicA.Add("PIER", dic);


                BlockTool.InsertBlockReference(pt4.Convert3D(20, -150), 1, _blcName, _dwgPath, dicA, null, ref ext);

                Point2d pNote = pt2.Convert2D(0, -2);



                tr.Commit();
                return tb;
            }
        }
        #endregion

        /// <summary>
        /// 挡板高度绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="scale"></param>
        /// <param name="dwgPath"></param>
        /// <param name="dtRes"></param>
        public static void DrawPlinthBlockDepthTable(Database db, double scale, string dwgPath, ref System.Data.DataTable dtRes)
        {
            Extents2d ext = new Extents2d(Point2d.Origin, Point2d.Origin);
            Extents2d ext1 = new Extents2d(Point2d.Origin, Point2d.Origin);
            Point2d CT = Point2d.Origin.Convert2D(0, -2 * scale);
            Point2d M1 = CT;
            ext = new Extents2d(M1, M1);

            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Desktop\P266-P291挡板高度.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Desktop\P266-P291挡板高度.csv");
            //System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\P-292-P-335垫石坐标.csv");
            System.Data.DataTable dt = CVSTools.OpenCSV(@"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-01\Banani EX-2 垫石坐标(1).csv");

            System.Data.DataTable dtP = new System.Data.DataTable();
            DataView dv0 = dt.DefaultView;
            dt = dv0.ToTable(true, new string[] { "Pier", "Side", "PlinthNo", "East", "North", "Height", "H0", "ZP_ABS" });
            Dictionary<int, List<string>> dic = new Dictionary<int, List<string>>();

            //List<string> pl = new List<string>() { "P266", "P267", "P268", "P269", "P270", "P271", "P272" };
            //dic.Add(1, pl);
            //List<string> p2 = new List<string>() { "P273", "P274", "P275", "P276", "P277", "P278", "P279", "P280" };
            //dic.Add(2, p2);
            //List<string> p3 = new List<string>() { "P281", "P282", "P283", "P284", "P285", "P286", "P287", "P288", "P289", "P290", "P291" };
            //dic.Add(3, p3);
            //List<string> pl = new List<string>() { "P-292", "P-293", "P-294", "P-295", "P-296", "P-297", "P-298", "P-299" };
            //dic.Add(1, pl);
            //List<string> p2 = new List<string>() { "P-300", "P-301", "P-302", "P-303", "P-304", "P-305", "P-306", "P-307" };
            //dic.Add(2, p2);
            //List<string> p3 = new List<string>() { "P-308", "P-309", "P-310", "P-311", "P-312", "P-313", "P-314", "P-315" };
            //dic.Add(3, p3);
            //List<string> p4 = new List<string>() { "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322" };
            //dic.Add(4, p4);
            //List<string> p5 = new List<string>() { "P-323", "P-324", "P-325", "P-326", "P-327", "P-328", "P-329" };
            //dic.Add(5, p5);
            //List<string> p6 = new List<string>() { "P-330", "P-331", "P-332", "P-333", "P-334", "P-335" };
            //dic.Add(6, p6);

            //List<string> pl = new List<string>() { "RP-11", "RP-12", "RP-13", "RP-14" };
            //dic.Add(1, pl);
            //List<string> p2 = new List<string>() { "RP-15", "RP-16", "RP-17" };
            //dic.Add(2, p2);
            List<string> p3 = new List<string>() { "RP-17" , "RP-18", "RP-19", "RP-20", "RP-21" };
            dic.Add(1, p3);

            int pageno = 1;
            for (int i = 0; i < pageno; i++)
            {
                //DataRow[] drsA = dt.Select("Pier='" + piername + "' and Side='A' and PlinthNo like '%-1'");
                //if (title == "Ⅰ-Ⅰ")
                //    drsA = dt.Select("Pier='" + piername + "' and Side='A' and PlinthNo like '%-1'");
                //else
                //    drsA = dt.Select("Pier='" + piername + "' and Side='B' and PlinthNo like '%-1'");

                //System.Data.DataTable dt0 = dt.Clone();
                //foreach (DataRow item in drsA)
                //{
                //    dt0.Rows.Add(item.ItemArray);
                //}
                List<string> pierL = dic[i + 1];
                System.Data.DataTable dtA = new System.Data.DataTable();
                System.Data.DataTable dtB = new System.Data.DataTable();
                dtA = dt.Clone();
                dtB = dt.Clone();
                if (pierL.Count > 0)
                {
                    foreach (string pierName in pierL)
                    {
                        DataRow[] drsA = dt.Select("Pier='" + pierName + "' and Side='A' and PlinthNo like '%-1'");

                        if (drsA.Length > 0)
                        {
                            foreach (DataRow item in drsA)
                            {
                                dtA.Rows.Add(item.ItemArray);
                            }
                        }
                        DataRow[] drsB = dt.Select("Pier='" + pierName + "' and Side='B' and PlinthNo like '%-1'");

                        if (drsB.Length > 0)
                        {
                            foreach (DataRow item in drsB)
                            {
                                dtB.Rows.Add(item.ItemArray);
                            }
                        }
                    }
                }

                Table lasTb = new Table();
                ext = new Extents2d(M1.Convert2D(0, -297 * i), M1.Convert2D(0, -297 * i));
                lasTb = DrawingPlinthBlockDepthTable(db, ref ext, M1.Convert3D(0, -297 * i),
                    Extensions.curFont, scale, dtA, dtB, dwgPath, pierL, ref dtRes);

                Common.CreateLayoutNew(db, "挡板厚度", ext, scale, 1, i, 0);
            }


        }
        /// <summary>
        /// 挡板高度表格绘制
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="startPoint"></param>
        /// <param name="txtStyle"></param>
        /// <param name="scale"></param>
        /// <param name="dtA"></param>
        /// <param name="dtB"></param>
        /// <param name="_dwgPath"></param>
        /// <param name="pierL"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static Table DrawingPlinthBlockDepthTable(Database db, ref Extents2d ext, Point3d startPoint,
string txtStyle, double scale, System.Data.DataTable dtA, System.Data.DataTable dtB, string _dwgPath, List<string> pierL, ref System.Data.DataTable dt)
        {

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                ObjectId id;
                TextStyleTable st = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                id = st[txtStyle];

                int rowNum = pierL.Count * 4 + 1;

                Table tb = new Table();
                #region  表格

                startPoint = startPoint.Convert3D();
                tb = new Table();
                int colNum = 5;
                tb.SetSize(rowNum, colNum);       // 设置几行几列
                tb.Position = startPoint;
                tb.GenerateLayout();

                #region 设置列宽
                // 设置列宽
                for (int i = 0; i < colNum; ++i)
                {
                    tb.Columns[i].Width = 6 * 3 * scale;
                }


                //行高
                for (int i = 0; i < rowNum; ++i)
                {
                    tb.Rows[i].Height = 5.68 * scale;
                }
                #endregion


                tb.Cells[0, 0].TextString = "Pier No."; //获取i行j列数据
                tb.Cells[0, 0].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 0].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 0].Contents[0].Rotation = 0;
                tb.Cells[0, 0].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 0].Contents[0].TextStyleId = id;



                tb.Cells[0, 1].TextString = "Station"; //获取i行j列数据
                tb.Cells[0, 1].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 1].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 1].Contents[0].Rotation = 0;
                tb.Cells[0, 1].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 1].Contents[0].TextStyleId = id;


                tb.Cells[0, 2].TextString = "H(m)"; //获取i行j列数据
                tb.Cells[0, 2].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 2].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 2].Contents[0].Rotation = 0;
                tb.Cells[0, 2].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 2].Contents[0].TextStyleId = id;


                tb.Cells[0, 3].TextString = "Station"; //获取i行j列数据
                tb.Cells[0, 3].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 3].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 3].Contents[0].Rotation = 0;
                tb.Cells[0, 3].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 3].Contents[0].TextStyleId = id;



                tb.Cells[0, 4].TextString = "H(m)"; //获取i行j列数据
                tb.Cells[0, 4].Contents[0].TextHeight = 2 * scale;
                tb.Cells[0, 4].Alignment = CellAlignment.MiddleCenter;
                tb.Cells[0, 4].Contents[0].Rotation = 0;
                tb.Cells[0, 4].Borders.Horizontal.Margin = 1 * scale;
                tb.Cells[0, 4].Contents[0].TextStyleId = id;
                int num = 1;
                for (int i = 0; i < pierL.Count; i++)
                {
                    try
                    {


                        string pierNo = "P-" + pierL[i].Replace("P", "").Replace("-", "");
                        tb.Cells[i * 4 + 1, 0].TextString = pierNo; //获取i行j列数据
                        tb.Cells[i * 4 + 1, 0].Contents[0].TextHeight = 2 * scale;
                        tb.Cells[i * 4 + 1, 0].Alignment = CellAlignment.MiddleCenter;
                        tb.Cells[i * 4 + 1, 0].Contents[0].Rotation = 0;
                        tb.Cells[i * 4 + 1, 0].Borders.Horizontal.Margin = 1 * scale;
                        tb.Cells[i * 4 + 1, 0].Contents[0].TextStyleId = id;
                        tb.MergeCells(CellRange.Create(tb, i * 4 + 1, 0, i * 4 + 4, 0));

                        double zp = 0;
                        double qxkH = 0;

                        DataRow[] drsA = dtA.Select("Pier='" + pierL[i] + "'");
                        for (int m = 0; m < 4; m++)
                        {

                            tb.Cells[i * 4 + 1 + m, 1].TextString = "A-" + (m + 1); //获取i行j列数据
                            tb.Cells[i * 4 + 1 + m, 1].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 4 + 1 + m, 1].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 4 + 1 + m, 1].Contents[0].Rotation = 0;
                            tb.Cells[i * 4 + 1 + m, 1].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 4 + 1 + m, 1].Contents[0].TextStyleId = id;

                            DataRow[] dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                            string h = "/";

                            if (pierL[i] != "P-297" && pierL[i] != "P-298"&&pierL[i] != "RP-17" )
                            {
                                if (pierL[i] == "P-325")
                                {
                                    if (m == 0)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (4) + "-%'");
                                    else if (m == 1)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (5) + "-%'");
                                    else if (m == 2)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (14) + "-%'");
                                    else
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (15) + "-%'");
                                }
                                else
                                {
                                    if (m == 0)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                                    else if (m == 1)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                                    else if (m == 2)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsA.Length - 2) + "-%'");
                                    else
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsA.Length - 1) + "-%'");
                                }
                                zp = double.Parse(dr[0]["ZP_ABS"].ToString());
                                if (zp == 0)
                                    qxkH = 0;
                                else if (zp < 0.015)
                                    qxkH = 0.0122;
                                else if (zp < 0.025)
                                    qxkH = 0.0144;
                                else if (zp < 0.035)
                                    qxkH = 0.0166;
                                else if (zp < 0.045)
                                    qxkH = 0.0188;
                                else if (zp < 0.055)
                                    qxkH = 0.0210;
                                else
                                    qxkH = 0.0232;
                                h = (double.Parse(double.Parse(dr[0]["Height"].ToString()).ToString("0.000")) + 0.089 + qxkH + 0.3).ToString();
                            }

                            tb.Cells[i * 4 + 1 + m, 2].TextString = h; //获取i行j列数据
                            tb.Cells[i * 4 + 1 + m, 2].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 4 + 1 + m, 2].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 4 + 1 + m, 2].Contents[0].Rotation = 0;
                            tb.Cells[i * 4 + 1 + m, 2].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 4 + 1 + m, 2].Contents[0].TextStyleId = id;

                            System.Data.DataRow drR = dt.NewRow();
                            drR[0] = num;
                            drR[1] = pierNo;
                            drR[2] = 0.089;
                            drR[3] = "A";
                            drR[4] = "A-" + (m + 1);
                            drR[5] = double.Parse(dr[0]["Height"].ToString()).ToString("0.000");
                            drR[6] = zp;
                            drR[7] = qxkH;
                            drR[8] = h;
                            dt.Rows.Add(drR);
                        }

                        DataRow[] drsB = dtB.Select("Pier='" + pierL[i] + "'");
                        for (int m = 0; m < 4; m++)
                        {

                            tb.Cells[i * 4 + 1 + m, 3].TextString = "B-" + (m + 1); //获取i行j列数据
                            tb.Cells[i * 4 + 1 + m, 3].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 4 + 1 + m, 3].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 4 + 1 + m, 3].Contents[0].Rotation = 0;
                            tb.Cells[i * 4 + 1 + m, 3].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 4 + 1 + m, 3].Contents[0].TextStyleId = id;

                            DataRow[] dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                            string h = "/";

                            if (pierL[i] != "P-296" && pierL[i] != "P-297" && pierL[i] != "P-335")
                            {
                                if (pierL[i] == "P-329")
                                {
                                    if (m == 0)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (4) + "-%'");
                                    else if (m == 1)
                                        dr = dtA.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (5) + "-%'");
                                    else if (m == 2)
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsB.Length - 2) + "-%'");
                                    else
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsB.Length - 1) + "-%'");
                                }
                                else
                                {
                                    if (m == 0)
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                                    else if (m == 1)
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (m + 1) + "-%'");
                                    else if (m == 2)
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsB.Length - 2) + "-%'");
                                    else
                                        dr = dtB.Select("Pier='" + pierL[i] + "' and PlinthNo like '" + (drsB.Length - 1) + "-%'");
                                }
                                zp = double.Parse(dr[0]["ZP_ABS"].ToString());
                                if (zp == 0)
                                    qxkH = 0;
                                else if (zp < 0.015)
                                    qxkH = 0.0122;
                                else if (zp < 0.025)
                                    qxkH = 0.0144;
                                else if (zp < 0.035)
                                    qxkH = 0.0166;
                                else if (zp < 0.045)
                                    qxkH = 0.0188;
                                else if (zp < 0.055)
                                    qxkH = 0.0210;
                                else
                                    qxkH = 0.0232;
                                h = (double.Parse(double.Parse(dr[0]["Height"].ToString()).ToString("0.000")) + 0.089 + qxkH + 0.3).ToString();
                            }

                            tb.Cells[i * 4 + 1 + m, 4].TextString = h; //获取i行j列数据
                            tb.Cells[i * 4 + 1 + m, 4].Contents[0].TextHeight = 2 * scale;
                            tb.Cells[i * 4 + 1 + m, 4].Alignment = CellAlignment.MiddleCenter;
                            tb.Cells[i * 4 + 1 + m, 4].Contents[0].Rotation = 0;
                            tb.Cells[i * 4 + 1 + m, 4].Borders.Horizontal.Margin = 1 * scale;
                            tb.Cells[i * 4 + 1 + m, 4].Contents[0].TextStyleId = id;


                            System.Data.DataRow drR = dt.NewRow();
                            drR[0] = num;
                            drR[1] = pierNo;
                            drR[2] = 0.089;
                            drR[3] = "B";
                            drR[4] = "B-" + (m + 1);
                            drR[5] = double.Parse(dr[0]["Height"].ToString()).ToString("0.000");
                            drR[6] = zp;
                            drR[7] = qxkH;
                            drR[8] = h;
                            dt.Rows.Add(drR);
                        }
                    }
                    catch (Exception ex)
                    {

                    }
                }

                tb.Layer = "细线";
                tb.LineWeight = LineWeight.LineWeight013;
                tb.ColorIndex = 4;
                modelSpace.AppendEntity(tb);
                tr.AddNewlyCreatedDBObject(tb, true);
                ext = ext.Add(new Extents2d(tb.Bounds.Value.MinPoint.Convert2D(), tb.Bounds.Value.MaxPoint.Convert2D()));

                #endregion

                #region 设置表格值

                #endregion

                #region 表格添加数据

                #endregion



                #region  边框粗线设置
                List<Point2d> pList = new List<Point2d>();
                Point2d pt1 = startPoint.Convert2D();
                pList.Add(pt1);
                Point2d pt2 = pt1.Convert2D(0, -tb.Height);
                pList.Add(pt2);
                Point2d pt3 = pt1.Convert2D(tb.Width, -tb.Height);
                pList.Add(pt3);
                Point2d pt4 = pt1.Convert2D(tb.Width, 0);
                pList.Add(pt4);
                PolylinePloter.AddPolylineByList(db, ref ext, pList, "粗线", 2);
                #endregion
                //string _blcName = "bufferdepth";
                //db.CopyBlockFromFile(_dwgPath, _blcName);

                //BlockTool.InsertBlockReference(pt4.Convert3D(-200, -10), 30, _blcName, _dwgPath, ref ext, 0);
                //_blcName = "bufferdepth3";
                //db.CopyBlockFromFile(_dwgPath, _blcName);

                //BlockTool.InsertBlockReference(pt4.Convert3D(-200, -150), 1, _blcName, _dwgPath, ref ext, 0);

                string Contents =
                      "Notes:\\P" +                      "1. All dimensions are in m unless otherwise indicated.\\P" +                      "2.The contractor shall verify all dimensions on site and resolve all discrepancies with the engineer & architect before commencement of work.\\P" +                      "3. All the produced unsuitable material shall be transport to the designate disposal area in a properly manner.\\P" +                      "4. All the site activities and operations shall follow the requirement of the approved Health and Safety Management Plan strictly.\\P" +
                      "5.Concrete shall have the minimum 45MPa of cylinder compressive strength at 28 days.\\P" +                      "6.Reinforcement steel shall have the minimum yield strength 500MPa.\\P" +                      "7.Concrete cover shall be 0.050m for concrete buffer.";
                TextPloter.PrintMultiText(db, ref ext, pt4.Convert3D(-270, -180), Contents, 1, 2.5, 200);
                //_blcName = "Model2";
                //db.CopyBlockFromFile(_dwgPath, _blcName);
                //Dictionary<string, Dictionary<string, string>> dicA = new Dictionary<string, Dictionary<string, string>>();
                //Dictionary<string, string> dic = new Dictionary<string, string>();
                //int pierNo = int.Parse(System.Text.RegularExpressions.Regex.Replace(pierName, @"[^0-9]+", "").ToString());
                //string stN = pierName.Replace(pierNo.ToString(), "") + (pierNo - 1);
                //string edN = pierName.Replace(pierNo.ToString(), "") + (pierNo + 1);

                //dic.Add(stN, "string");
                //dicA.Add("NOS", dic);

                //dic = new Dictionary<string, string>();
                //dic.Add(edN, "string");
                //dicA.Add("NOE", dic);

                //BlockTool.InsertBlockReference(pt4.Convert3D(20, -150), 1, _blcName, _dwgPath, dicA, null, ref ext);

                //BlockTool.InsertBlockReference(pt4.Convert3D(45, -90), 1, _blcName, _dwgPath, ref ext, 0);
                Point2d pNote = pt2.Convert2D(0, -2);



                tr.Commit();
                return tb;
            }
        }
    }
}
